<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" isELIgnored="false" %>
<div class="panel panel-info">
    <div class="panel-heading">
        <h3 class="panel-title" style="display: inline-block">查询</h3>
    </div>
    <div class="panel-body">
        <div class="form-horizontal row">
            <form id="form_manual">
                <div class="form-group col-sm-5">
                    <label class="col-sm-4 control-label">专家姓名：</label>
                    <div class="col-sm-8">
                        <input class="form-control" type="text" name="name">
                    </div>
                </div>
                <div class="form-group col-sm-5 ">
                    <label class="control-label col-sm-4 ">专家类型：</label>
                    <div class="col-sm-8">
                        <select class="form-control " name="gradeList" multiple>
                            <option value="AA">AA</option>
                            <option value="A">A</option>
                            <option value="B">B</option>
                            <option value="C">C</option>
                        </select>
                    </div>
                </div>

                <div class="form-group col-sm-5">
                    <label class="col-sm-4 control-label">开始时间：</label>
                    <div class="col-sm-8">
                        <div class="input-group date form_date  timeInput">
                                                <span class="input-group-addon">
                                                    <span class="glyphicon glyphicon-calendar"></span>
                                                </span>
                            <input id="startTime_1" class="form-control " type="text" name="startTime"
                                   value="2017-05-01">
                        </div>
                    </div>
                </div>
                <div class="form-group col-sm-5">
                    <label class="col-sm-4 control-label">结束时间：</label>
                    <div class="col-sm-8">
                        <div class="input-group date form_date  timeInput">
                                                <span class="input-group-addon">
                                                    <span class="glyphicon glyphicon-calendar"></span>
                                                </span>
                            <input id="endTime_1" class="form-control" type="text" name="endTime" value="2017-05-01">
                        </div>
                    </div>
                </div>
                <div class="form-group col-sm-10">
                    <label class="control-label col-sm-2">专　　业：</label>
                    <div class="col-sm-9">
                        <input type="text" readonly id="citySel1" class="form-control">
                        <div id='menuContent1'
                             style="display: none; position: relative; height: 0px;z-index: 100">
                            <div style="background-color: #f5f5f5;border: 1px solid #ccc">
                                <div style="overflow-y:auto; overflow-x:auto; max-height: 200px; ">
                                    <ul id="treeDemo1" class="ztree"></ul>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="form-group col-sm-5">
                    <label class="col-sm-4 control-label">是否外省：</label>
                    <div class="col-sm-8">
                        <select class="form-control  " name="outLander">
                            <option value="">&nbsp;</option>
                            <option value="1">是</option>
                            <option value="0">否</option>
                        </select>
                    </div>
                </div>
                <div class="form-group col-sm-5">
                    <label class="col-sm-4 control-label">所属单位：</label>
                    <div class="col-sm-8">
                        <input class="form-control" type="text" name="affiliateCompany">
                    </div>
                </div>
                <div class="form-group col-sm-5">
                    <div class="col-sm-8 col-sm-offset-4">
                        <button type="button" id="btn_manuel"
                                class="btn btn-default   ">
                            <span class="glyphicon glyphicon-search"></span>&nbsp;抽&nbsp;取&nbsp;
                        </button>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
<table id="table_search_manual"></table>

<script>
    $(function () {
        var selectTree = new ApmZTreeUtil(
                $("#citySel1"),
                $("#menuContent1"),
                $("#treeDemo1")
        ), setting = {
            check: {
                enable: true,
                checkboxType: {"Y": "", "N": ""}
            },
            view: {
                dblClickExpand: false
            },
            data: {
                simpleData: {
                    enable: true
                }
            },
            async: {
                enable: true,
                url: "${base}/httpPage/getTreeByBusinessId",
                otherParam: {"businessId": '${business.id}'}
            },
            callback: {
                beforeClick: selectTree.beforeClick,
                onCheck: selectTree.onCheck,
                onAsyncSuccess: selectTree.onCheck
            }
        };
        $("#citySel1").on('click', function () {
            selectTree.showMenu();
        });
        $.fn.zTree.init($("#treeDemo1"), setting);
    });


    $(function () {

        $("#btn_manuel").click(function () {
            var date1 = new Date(Date.parse($("#startTime_1").val().replace("-", "/")));
            var date2 = new Date(Date.parse($("#endTime_1").val().replace("-", "/")));
            if (date1 > date2) {
                alert("开始时间不能小于结束时间");
                return;
            }
            $("#table_search_manual").bootstrapTable('refresh');
        });


        $("#table_search_manual").bootstrapTable({
            url: '${base}/httpPage/manuallyExtractionExpert',
            striped: true,
            cache: false,
            sidePagination: 'server',
            searchOnEnterKey: false,
            pageSize: 10,
            pageList: [ 10,20,30,40,50,100],
            pageNumber: 1,
            pagination: true,
            queryParams: function (params) {
                var treeObj = $.fn.zTree.getZTreeObj("treeDemo1");
                var nodes = treeObj.getCheckedNodes(true);
                var ids = new Array();
                for (var i = 0; i < nodes.length; i++) {
                    if (!nodes[i].isParent)
                        ids.push(nodes[i].data);
                }

                if (ids.length > 300) {
                    alert("勾选的专业过多");
                }

                console.log(ids);
                $.extend(params, $("#form_manual").serializeObject());
                params.majorNumList = ids.toString();
                params.businessCode = '${business.businessCode}';
                params.gradeList=params.gradeList&&params.gradeList.toString();
                return params;
            },
            columns: [
                {
                    formatter: function (value, row, index) {
                        return index + 1;
                    }
                },
                {
                    title: '姓名',
                    field: 'name',
                    formatter: function (value, row, index) {
                        return [
                            '<div class="nameClick" ><a href="javascript:;" style="text-decoration: none ;display: block;width: 60px">' + value + '</a></div>'
                        ].join('');
                    },
                    events: 'events'
                },

                {
                    field: 'idCard',
                    title: '身份证号码',
                    visible: false
                },
                {
                    field: 'grade',
                    title: '专家类型'
                },
                {
                    field: 'phone',
                    title: '手机号码'
                },
                {
                    field: 'workCompany',
                    title: '单位',
                    visible: false
                },
                {
                    field: 'affiliateCompany',
                    title: '所属单位'
                },
                {
                    field: 'reviewTimes',
                    title: '今年审查（评审）次数'
                },
                {
                    field: 'result',
                    title: '结果',
                    formatter: function (value, row, index) {
                        if (value == 1) {
                            return '能去';
                        } else {
                            return '不能去';
                        }
                    }
                },
                {
                    field: 'reason',
                    title: '备注'
                },
                {
                    title: '操作',
                    events: 'events',
                    formatter: function (value, row, index) {

                        var data = $("#table_result").bootstrapTable('getOptions').data, str = "";
                        for (var i = 0; i < data.length; i++) {
                            if (row.idCard == data[i].idCard) {
                                str = 'disabled';
                            }
                        }
                        return [
                            '<button ' + str + ' type="button" class="btn btn-xs btn-default  checkExpert ">' +
                            '<span class="glyphicon glyphicon-check  "></span> 选择' +
                            '</button>'
                        ].join('');
                    }
                }
            ]
        });
    })
</script>
